home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / demos / GL / curve / event.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-02  |  3.2 KB  |  85 lines

  1. /*
  2.  * Copyright 1991, 1992, 1993, 1994, Silicon Graphics, Inc.
  3.  * All Rights Reserved.
  4.  *
  5.  * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  6.  * the contents of this file may not be disclosed to third parties, copied or
  7.  * duplicated in any form, in whole or in part, without the prior written
  8.  * permission of Silicon Graphics, Inc.
  9.  *
  10.  * RESTRICTED RIGHTS LEGEND:
  11.  * Use, duplication or disclosure by the Government is subject to restrictions
  12.  * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  13.  * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  14.  * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  15.  * rights reserved under the Copyright Laws of the United States.
  16.  */
  17. /*
  18.  *    event.h
  19.  * External interface and defines to input-queue event handling
  20.  * routines.
  21.  * Written by Wade Olsen for Silicon Graphics, Inc.
  22.  */
  23.  
  24. /*
  25.  *    The event handler understands two kinds of things; events and
  26.  * updates.  Events are reactions to things occuring in the input
  27.  * queue.  Updates are functions that should be called whenever there
  28.  * is nothing waiting in the input queue, and may be active or
  29.  * inactive.  If there are no active updates and nothing in the input
  30.  * queue, then event() will block, using up no CPU time.
  31.  *
  32.  * add_event is used to look for events.  The first three arguments
  33.  * are used to identify which event to look for.  The first argument
  34.  * is the window (gid) the event must happen in; if this value is ANY
  35.  * then any window will do.  The second argument is the device to look
  36.  * for (e.g.  RIGHTMOUSE or REDRAW or KEYBD, etc).  Again, if it is
  37.  * ANY then any device will match.  The third argument is the value
  38.  * the device must generate (e.g.  DOWN or UP); ANY means all values
  39.  * match.  The last two arguments are what should be done when an
  40.  * event is generated.  The fourth argument is a function to be
  41.  * called, and the fifth is an argument that should be supplied to the
  42.  * function.  In addition, the value generated by the device will also
  43.  * be passed to the function when it is called.
  44.  *
  45.  * For example,
  46.  *    add_event(winget(), RIGHTMOUSE, DOWN, dopup, my_menus);
  47.  *    qdevice(RIGHTMOUSE);
  48.  * will make a pop-up menu appear when the right mousebutton goes
  49.  * down.  Note that you must do the qdevice() call yourself.
  50.  */
  51. void add_event(int, int, int, void (*fn)(void *, int), char *) ;
  52.  
  53. /*
  54.  * An update is like an event, only simpler.  The first argument is a
  55.  * pointer to an integer flag specifying whether or not this update
  56.  * function is active.  The second is a function to be called when it
  57.  * is active, and the last is an argument to be supplied to the
  58.  * function.
  59.  */
  60. void add_update(int *, void (*fn)(void *), char *) ;
  61.  
  62. /*
  63.  * Finally, when all updates and events have been added, repeatedly
  64.  * call event() to handle them -- something like
  65.  * 
  66.  *    while (quitflag == FALSE) event();
  67.  * 
  68.  * You should have previously added an event that sets quitflag to
  69.  * TRUE, of course.
  70.  */
  71. void event(void) ;
  72.  
  73. /*
  74.  *    These are some useful defines for the possible values buttons
  75.  * can generate.
  76.  */
  77. #define ANY    -1
  78. #define UP    0
  79. #define DOWN    1
  80.  
  81. /*
  82.  *    And a few external variables you might find useful
  83.  */
  84. extern int context, state, device;
  85.